<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@include file="../base.jsp" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="${path}/js/jquery/easyui1.5/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="${path}/js/jquery/easyui1.5/themes/icon.css">
<script type="text/javascript" src="${path}/js/jquery-1.8.0.min.js"></script>
<script src="${path}/js/jquery/easyui1.5/jquery.easyui.min.js"></script>
<script src="${path}/js/jquery/easyui1.5/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${path}/js/jquery.select.js"></script>

	<link rel="stylesheet" type="text/css" href="${path}/admin123/css/footer.css">

	<script type="text/javascript">
	//dialog buttons
	var jsonParam_buttons=[{
		text:'提交',
		iconCls:'icon-save',
		handler:function(){
			 save();
		}
	},{
		text:'关闭',
		iconCls:'icon-cancel',
		handler:function(){
			window.parent.closeDialog();
		}
	}];

	var row;
	var id;
	var loginname;
	$(function(){
		//add buttons to dialog
		window.parent.addButtons2IframeDialog(jsonParam_buttons);

		row = '${paramValues.row[0]}';
		row = decodeURI(row);
		row = JSON.parse(row);
		loginname = row.loginname;
		id = row.id;
		$("#my_loginName").val(loginname);

		$('#tt11').tree({
			url:'${path}/admin123/right_v2/securityv2Ajax_queryRoleListByUserid.action',
			queryParams:{'userId':id},
			checkbox:true
		});

	});

	function save(){
		//取树NODES
		var nodes = $('#tt11').tree('getChecked');
		//var nodes1 = JSON.stringify(nodes);
		//alert(nodes1);
		var Ids = new Array();
		for(var i=0; i<nodes.length; i++){
			var node = nodes[i];
			var id1 = node.id;
			Ids[i] = id1;
		}

		$.ajax({
			type:"POST",
			url:'${path}/admin123/right_v2/securityv2Ajax_updateRoleListByUserid.action',
			dataType:"json",
			data:{'userId':id,'selectedRoleNodes':JSON.stringify(Ids)},
			success:function(msg){
				window.parent.messager_show(msg,2000);
				window.parent.datagrid_fresh();
				window.parent.closeDialog();
			},
			error:function(er){
				//alert(er.responseText.trim());
				window.parent.error(er);
			}
		});
	}
	</script>

</head>
<body >
	<div style="margin: 0px;">
		用户名：<input type="text" id="my_loginName" readonly="readonly"/>
	</div>
	<br/>
	<ul id="tt11"></ul>
	<%--<div>
		<a id="my_savaRoleList" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'">确认保存新的用户角色</a>
	</div>--%>
</body>
</html>